package 设计模式.策略模式;

import java.util.HashMap;
import java.util.Map;

public class PromotionStategyFactory {
    private static Map<String,PromotionStrategy> PROMOTION_STRATEGY_MAP  = new HashMap<>();
    static{
        PROMOTION_STRATEGY_MAP.put("fanxian",new FanXianPromotionStrategy());
        PROMOTION_STRATEGY_MAP.put("lijian",new LijianPromotionStrategy());
        PROMOTION_STRATEGY_MAP.put("manjian",new ManJianPromotionStrategy());
    }
    private static final PromotionStrategy NO_PROMOTIONSTRATEGY = new EmptyPromotionStrategy();

    private PromotionStategyFactory() {
    }

    public static PromotionStrategy getPromotionStategy(String key){
        PromotionStrategy promotionStrategy = PROMOTION_STRATEGY_MAP.get(key);
        return promotionStrategy==null ? NO_PROMOTIONSTRATEGY:promotionStrategy;
    }
}
